package com.TeacherInfoServer.pojo.entity;

import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.baomidou.mybatisplus.annotation.*;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.Getter;
import lombok.NoArgsConstructor;

import static io.swagger.v3.oas.annotations.media.Schema.AccessMode.READ_ONLY;

/**
 * 教师信息类
 */

@Data
@AllArgsConstructor
@NoArgsConstructor
@TableName("teacher")
@Schema(name = "教师信息类")
public class Teacher {
    @TableId(value = "id",type = IdType.AUTO)
    @Schema(accessMode = READ_ONLY)
    @ExcelIgnore
    private Integer id;

    @TableField("teacher_id")
    @ExcelProperty(value = "工号",index = 0)
    @ColumnWidth(20)
    private String teacherId;

    @TableField("teacher_name")
    @ExcelProperty(value = "姓名",index = 1)
    @ColumnWidth(20)
    private String teacherName;

    @TableField("gender")
    @ExcelProperty(value = "性别",index = 2)
    @ColumnWidth(10)
    private String gender;

    @TableField("birth_date")
    @ExcelProperty(value = "出生日期",index = 3)
    @ColumnWidth(20)
    private String birthDate;

    @TableField("id_card_number")
    @ExcelProperty(value = "身份证号码",index = 4)
    @ColumnWidth(20)
    private String idCardNumber;

    @TableField("job_title_id")
    @ExcelProperty(value = "现职称",index = 5)
    @ColumnWidth(20)
    private Integer jobTitleId;

    @TableField("department_id")
    @ExcelProperty(value = "现在教研室",index = 6)
    @ColumnWidth(20)
    private Long departmentId;

    @TableField("degree_id")
    @ExcelProperty(value = "学位",index = 7)
    @ColumnWidth(10)
    private Integer degreeId;

    @TableField("educated_id")
    @ExcelProperty(value = "学历",index = 8)
    @ColumnWidth(10)
    private Integer educatedId;

    @TableField("ethnic_id")
    @ExcelProperty(value = "民族",index = 9)
    @ColumnWidth(10)
    private Integer ethnicId;

     @TableField("college_id")
     @ExcelProperty(value = "学院",index = 10)
     @ColumnWidth(10)
     private Integer collegeId;

     @TableField("age")
     @ExcelProperty(value = "年龄",index = 11)
     @ColumnWidth(10)
     private Integer age;

    @Version
    @TableField("version")
    @ExcelIgnore
    private Integer version;



    @Getter
    @AllArgsConstructor
    public enum IdFieldName {
        JOB_TITLE_ID("job_title_id","职称类型"),
        DEGREE_ID("degree_id","学位类型"),
        EDUCATED_ID("educated_id","学历类型"),
        // TODO: 2024-5-18 民族类型和学院类型存在问题，待修复
        ETHNIC_ID("ethnic_id","民族类型"),
        COLLEGE_ID("college_id","学院类型");
        private final String value;
        private final String typename;

        public static String getValueByTypename(String typename) {
            String value = null;
            for (IdFieldName idFieldName : IdFieldName.values()) {
                if (idFieldName.getTypename().equals(typename)) {
                    value = idFieldName.getValue();
                }
            }
            return value;
        }
    }
}
